package controlador;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.List;

import vista.ReporteIngredientes;
import vista.ReporteIngredientesModeloTablaIng;

import modelo.Ingrediente;
import modelo.IngredienteDAO;


public class ControladorReporteIngredientes implements ActionListener{

	private ReporteIngredientes reporteIngredientes;

	public ControladorReporteIngredientes() {
		super();
		this.reporteIngredientes = new ReporteIngredientes();
		this.reporteIngredientes.addListener(this);
		this.reporteIngredientes.setLocationRelativeTo(null);
		this.reporteIngredientes.setVisible(true);
		cargarReporte();
		
	}

	@Override
	public void actionPerformed(ActionEvent e) {
		reporteIngredientes.dispose();
		
	}
	
	public void cargarReporte(){
		IngredienteDAO ingredienteDAO = new IngredienteDAO();
		List<Ingrediente> ingredientes = ingredienteDAO.consultarIngredientes();
		reporteIngredientes.setTablaIngredientes( new ReporteIngredientesModeloTablaIng(ingredientes));
	}
	
}
